package com.njwb.day09.exception;

import java.util.InputMismatchException;
import java.util.Scanner;

public class Test03 {


    public static void main(String[] args) {
        int value = getSum();
        System.out.println(value);
    }



    public static int getSum(){
        Scanner in = new Scanner(System.in);
        int sum=0 ;
        try{
            System.out.print("请输入第一个数字");
            int num1 = in.nextInt();
            System.out.print("请输入第二个数字:");
            int num2 = in.nextInt();
            sum = num1+num2;
            //返回到方法的调用处。结束
            return sum;
        }catch(InputMismatchException e) {
            e.printStackTrace();
            return -1;
        }finally {
            System.out.println("感谢使用本程序！");
        }
    }

}
